home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 25 / AACD 25.iso / AACD / Magazine / Online / QMail / patches / qmail-smtproutesip.diff < prev   
Encoding:
Text File  |  1997-10-02  |  2.3 KB  |  85 lines

  1. diff -u ../qmail-1.01-unmodified/qmail-remote.c ./qmail-remote.c
  2. --- ../qmail-1.01-unmodified/qmail-remote.c    Tue Apr 15 07:05:23 1997
  3. +++ ./qmail-remote.c    Thu Oct  2 10:14:29 1997
  4. @@ -41,6 +41,8 @@
  5.  stralloc helohost = {0};
  6.  stralloc routes = {0};
  7.  struct constmap maproutes;
  8. +stralloc routesip = {0};
  9. +struct constmap maproutesip;
  10.  stralloc host = {0};
  11.  stralloc sender = {0};
  12.  
  13. @@ -114,6 +116,16 @@
  14.     case 1:
  15.       if (!constmap_init(&maproutes,routes.s,routes.len,1)) temp_nomem(); break;
  16.    }
  17. +
  18. + switch(control_readfile(&routesip,"control/smtproutesip",0))
  19. +  {
  20. +   case -1:
  21. +     if (errno == error_nomem) temp_nomem(); temp_control();
  22. +   case 0:
  23. +     if (!constmap_init(&maproutesip,"",0,1)) temp_nomem(); break;
  24. +   case 1:
  25. +     if (!constmap_init(&maproutesip,routesip.s,routesip.len,1)) temp_nomem(); break;
  26. +  }
  27.  }
  28.  
  29.  char smtptobuf[1024];
  30. @@ -461,12 +473,53 @@
  31.    {
  32.     int s;
  33.  
  34. +   /* Map IP numbers according to control/smtproutesip. */
  35. +   unsigned int j;
  36. +   int len;
  37. +   char hostip[16]; /* Enough to hold xxx.xxx.xxx.xxx */
  38. +   ipalloc ip2 = {0};
  39. +   stralloc host2 = {0};
  40. +   char *relayhost2 = 0;
  41. +   unsigned long connport = port, port2 = port;
  42. +
  43. +   hostip[len = ip_fmt (hostip,&ip.ix[i].ip)] = '\0';
  44. +
  45. +   for (j = len; (signed int) j > -1; j --)
  46. +     if ((j == len) || (j == 0) || (hostip[j - 1] == '.'))
  47. +       if ((relayhost2 = constmap (&maproutesip, hostip, j)))
  48. +         break;
  49. +   if (relayhost2 && !*relayhost2) relayhost2 = 0;
  50. +
  51. +   if (relayhost2)
  52. +   {
  53. +     j = str_chr(relayhost2,':');
  54. +     if (relayhost2[j])
  55. +      {
  56. +       scan_ulong(relayhost2 + j + 1,&port2);
  57. +       relayhost2[j] = 0;
  58. +      }
  59. +     if (!stralloc_copys(&host2,relayhost2)) temp_nomem();
  60. +
  61. +     switch (dns_ip (&ip2, &host2))
  62. +     {
  63. +       case DNS_HARD: break;
  64. +       case DNS_SOFT: temp_dns ();
  65. +       case DNS_MEM:  temp_nomem ();
  66. +       case 1:
  67. +         if (ip2.len <= 0) temp_dns();
  68. +     }
  69. +
  70. +     ip.ix[i].ip = ip2.ix[0].ip;
  71. +     connport = port2;
  72. +     if (!stralloc_copy(&host,&host2)) temp_nomem ();
  73. +   }
  74. +
  75.     if (tcpto(&ip.ix[i].ip)) continue;
  76.  
  77.     s = socket(AF_INET,SOCK_STREAM,0);
  78.     if (s == -1) temp_oserr();
  79.  
  80. -   if (timeoutconn(s,&ip.ix[i].ip,(unsigned int) port,timeoutconnect) == 0)
  81. +   if (timeoutconn(s,&ip.ix[i].ip, connport,timeoutconnect) == 0)
  82.      {
  83.       tcpto_err(&ip.ix[i].ip,0);
  84.       partner = ip.ix[i].ip;
  85.